package com.supermarket_project.common;


import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

/**
 * Created with IntelliJ IDEA.
 * User: ljc
 * Date: 2022/07/07 9:17
 * Description:
 * Version: V1.0
 * note:
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class R <T>{
    private int code;
    private String msg;
    private T data;
    public static <T> R<T> success(T object,String msg) {
        R<T> r = new R<T>();
        r.data = object;
        r.code = 200;
        r.msg=msg;
        return r;
    }

    public static <T> R<T> error(String msg) {
        R r = new R();
        r.msg = msg;
        r.code = 500;
        r.setData(null);
        return r;
    }
}
